%% Carbon Taxes Around the World: Cooperation, Strategic Interactions, and Spillovers
% IMF Economic Review
% Alessandro Moro and Valerio Nispi Landi
% Replication files
% This file plots Figure 2

clc; close all; clear all;

console;
BASE=1;                % This is the baseline carbon policy
console_final_opt;
dynare climate


SAVE_BASE=1;
SAVE=0;
load dice               % Imported from the xls file
%load base

% Transform annual series in 5-year series, to make the comparison with DICE
dd=zeros(T,1);
dd(1)=1;
for j=1:5:T
dd(j)=1;
end
xs=nonzeros(xs(1:T).*dd);
temps=nonzeros(temps(1:T).*dd);
prices=nonzeros(prices(1:T).*dd);
mus=nonzeros(mu(1:T).*dd);

if SAVE_BASE==1
mus=nonzeros(mu(1:T).*dd);
xs_base=xs;
temps_base=temps;
prices_base=prices;
mus_base=mus;
save base xs_base temps_base prices_base mus_base
end


% Plot baseline X vs baseline X in Dice model
if BASE==1
usedfont='Georgia';
FigW=17;
FigH=FigW;
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
plot([2020:5:2420], xs_base,'k','Linewidth',2)
hold on
plot([2020:5:2420],dice(1:(T-1)/5+1,2),'r:','Linewidth',2)
set(gca,'XTick',2020:50:2420)
axis tight
ax = gca;
ax.FontSize = 14; 
ax.YAxis.Exponent = 0;
%title('Atmospheric carbon (GtC)','Fontsize',18,'fontweight','bold')
xlabel('Years','Fontsize',14,'fontweight','bold')
ylabel('GtC','Fontsize',14,'fontweight','bold')
legend('Our model: baseline policy','DICE: baseline policy','Location','Southeast','Fontsize',14)   
if SAVE==1
print('-dpng','-r500',['./figures/Xbase.png'])
end
return    
end    

usedfont='Georgia';
FigW=35;
FigH=FigW;
figure;
set(gcf,'color', 'white',...
        'PaperUnits','centimeters','PaperSize',[FigW FigH],...
        'PaperPosition',[0,0,FigW,FigH],'PaperPositionMode','manual',...
        'Units','centimeters',...
        'Position',[0,0,FigW,FigH]);
subplot(2,2,1)
plot(xs,'b','Linewidth',2)
hold on
plot(dice(:,6),'b:','Linewidth',2)
hold on
plot(xs_base,'r','Linewidth',2)
hold on
plot(dice(:,2),'r:','Linewidth',2)
axis tight
title('Atmospheric carbon','Fontsize',14,'fontweight','bold')
legend('Optimal','Dice opt.','Base','Dice base','Location','Northwest','Fontsize',12)
subplot(2,2,2)
plot(temps,'b','Linewidth',2)
hold on
plot(dice(:,8),'b:','Linewidth',2)
hold on
plot(temps_base,'r','Linewidth',2)
hold on
plot(dice(:,4),'r:','Linewidth',2)
axis tight
title('Temperature (� celsius)','Fontsize',14,'fontweight','bold')
subplot(2,2,3)
plot(mus,'b','Linewidth',2)
hold on
plot(dice(:,5),'b:','Linewidth',2)
hold on
plot(mus_base,'r','Linewidth',2)
hold on
plot(dice(:,1),'r:','Linewidth',2)
axis tight
title('Control rate','Fontsize',14,'fontweight','bold')
subplot(2,2,4)
plot(prices,'b','Linewidth',2)
hold on
plot(dice(:,7),'b:','Linewidth',2)
hold on
plot(prices_base,'r','Linewidth',2)
hold on
plot(dice(:,3),'r:','Linewidth',2)
axis tight
title('Carbon price $/tCo2','Fontsize',14,'fontweight','bold')